package com.lcw.framework.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.lcw.framework.util.FileUploadUtil;

@Controller
public class uploadFileController {

	@RequestMapping("UserControllers/progress")  
	public void uploadFile(HttpServletRequest request,HttpServletResponse response,  
	                       @RequestParam("file") CommonsMultipartFile file) throws IOException {  
	     response.setContentType("text/html");  
	     response.setCharacterEncoding("GBK");  
	     PrintWriter out;  
	     boolean flag = false;  
	     if (file.getSize() > 0) {  
	          //文件上传的包，上传位置可以在里面自定义  
	         flag = FileUploadUtil.uploadFile(request, file);  
	     }  
	     out = response.getWriter();  
	     if (flag == true) {  
	        out.print("1");  
	     } else {  
	        out.print("2");  
	     }  
	}  
}
